package Test;

import javax.swing.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class MyJFrame2 extends JFrame implements MouseListener {

    //创建按钮图像
    JButton jtb = new JButton("click");

    public MyJFrame2() {
        this.setSize(603, 680);

        this.setTitle("拼图游戏 V0.99");

        //置顶
        this.setAlwaysOnTop(true);

        //界面居中
        this.setLocationRelativeTo(null);

        //关闭模式
        this.setDefaultCloseOperation(3);

        //取消默认布局模式（居中） 取消后才是按XY布局的模式
        this.setLayout(null);

        //设置位置大小
        jtb.setBounds(0, 0, 100, 50);

        //绑定鼠标事件
        jtb.addMouseListener(this);

        this.getContentPane().add(jtb);
        this.setVisible(true);

    }

    @Override
    public void mouseClicked(MouseEvent e) {
        System.out.println("单击");
    }

    @Override
    public void mousePressed(MouseEvent e) {
        System.out.println("单击不松");
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        System.out.println("松开");
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        System.out.println("划入");
    }

    @Override
    public void mouseExited(MouseEvent e) {
        System.out.println("划出");
    }
}
